*Census ELF data used in Chapters 4 and 10; all regressions only include 50k or higher population

*Table 4.3: Industrialization and Ethnic Change with Census Data
*No Controls
xtreg elf lCO2pc MStock TT if pop50k==1 [aweight=Countryweight], fe cluster (countryid)
*controlling for GDP per capita
xtreg elf lCO2pc MStock TT lGDPpc if pop50k==1 [aweight=Countryweight], fe cluster (countryid)
*controlling for democracy
xtreg elf lCO2pc MStock TT v2x_polyarchy if pop50k==1 [aweight=Countryweight], fe cluster (countryid)
*controlling for schooling
xtreg elf lCO2pc MStock TT yr_sch if pop50k==1 [aweight=Countryweight], fe cluster (countryid)
*controlling for taxation as a % of GDP
xtreg elf lCO2pc MStock TaxGDP TT if pop50k==1 [aweight=Countryweight], fe cluster (countryid)
*controlling for infant mortality
xtreg elf lCO2pc MStock TT lIMortality if pop50k==1 [aweight=Countryweight], fe cluster (countryid)
*Using largest Ethnic Group as a dependent variable
xtreg LargestEG lCO2pc MStock TT if pop50k==1 [aweight=Countryweight], fe cluster (countryid)

*Table 4.4: Industrialization and Ethnic Change Using Census Data, with Alternative Measures of Industrialization
xtreg elf lCement MStock TT if pop50k==1 [aweight=Countryweight], fe cluster (countryid)
xtreg elf Urban MStock TT if pop50k==1 [aweight=Countryweight], fe cluster (countryid)
xtreg elf lElectricityUSEIA MStock TT if pop50k==1 [aweight=Countryweight], fe cluster (countryid)
xtreg elf AgEmploy MStock TT if pop50k==1 [aweight=Countryweight], fe cluster (countryid)
xtreg elf ManufactEmploy MStock TT if pop50k==1 [aweight=Countryweight], fe cluster (countryid)

*Figure 4.2: change in lCO2 and change in ELF, elimiating outliers of Brunei and Seychelles
replace clock=3
replace clock=9 if ISO=="ABW"
replace clock=4 if ISO=="ALB"
replace clock=6 if ISO=="AUS"
replace clock=12 if ISO=="AUT"
replace clock=9 if ISO=="BWA"
replace clock=9 if ISO=="GBR"
replace clock=12 if ISO=="GRD"
replace clock=9 if ISO=="HUN"
replace clock=2 if ISO=="KAZ"
replace clock=12 if ISO=="LCA"
replace clock=9 if ISO=="MAC"
replace clock=12 if ISO=="MUS"
replace clock=9 if ISO=="NCL"
replace clock=9 if ISO=="ROU"
replace clock=8 if ISO=="TJK"
replace clock=1 if ISO=="VNM"
replace clock=9 if ISO=="ZMB"
replace clock=6 if ISO=="ZAF"
twoway (lfitci dELF dCO2) (scatter dELF dCO2, mlabel(ISO) msize(small) mcolor(black) mlabcolor(black) mlabvpos(clock)) if dCO2>-1 & dCO2<2, ytitle(Change in ELF) xtitle(Change in Carbon Emissions per capita (log)) legend(off)

*Figure 4.3: Change in Agricultural Employment and Change in ELF
replace clock=3
replace clock=12 if ISO=="BEN"
replace clock=4 if ISO=="BLR"
replace clock=9 if ISO=="BLZ" & year==2010
replace clock=6 if ISO=="BRA"
replace clock=9 if ISO=="BRN"
replace clock=9 if ISO=="BGR"
replace clock=12 if ISO=="CHN"
replace clock=6 if ISO=="COL"
replace clock=8 if ISO=="EST"
replace clock=2 if ISO=="FIN"
replace clock=9 if ISO=="GEO"
replace clock=11 if ISO=="GUY"
replace clock=9 if ISO=="GUY" & year==2002
replace clock=9 if ISO=="HKG"
replace clock=12 if ISO=="IND"
replace clock=6 if ISO=="KHM"
replace clock=6 if ISO=="IRL"
replace clock=11 if ISO=="LAO" & year==2015
replace clock=8 if ISO=="LAO" & year==2005
replace clock=9 if ISO=="LKA"
replace clock=10 if ISO=="LTU"
replace clock=9 if ISO=="MKD"
replace clock=6 if ISO=="MNG"
replace clock=9 if ISO=="NZL" & dELF>.2
replace clock=6 if ISO=="POL"
replace clock=9 if ISO=="PRI"
replace clock=6 if ISO=="ROU" & dAgEmploy>0
replace clock=9 if ISO=="TTO"
replace clock=12 if ISO=="SVN"
replace clock=12 if ISO=="UGA"
replace clock=9 if ISO=="VNM"
replace clock=6 if ISO=="ZAF"
replace clock=9 if ISO=="ZMB"
twoway (lfitci dELF dAgEmploy) (scatter dELF dAgEmploy, mlabel(ISO) msize(small) mcolor(black) mlabcolor(black) mlabvpos(clock)) if dELF>-.2, ytitle(Change in ELF) xtitle(Change in Employment in Agriculture) legend(off)

*Figure 4.4: Change in Industrial Employment and Change in ELF
replace clock=3
replace clock=12 if ISO=="BEN"
replace clock=9 if ISO=="BGR"
replace clock=9 if ISO=="BIH"
replace clock=9 if ISO=="BLR"
replace clock=4 if ISO=="BLZ"
replace clock=9 if ISO=="BRN"
replace clock=12 if ISO=="CAN"
replace clock=4 if ISO=="CHN"
replace clock=7 if ISO=="EST"
replace clock=9 if ISO=="HKG"
replace clock=10 if ISO=="IRL" & dIndEmploy>0
replace clock=8 if ISO=="JAM"
replace clock=11 if ISO=="KEN"
replace clock=9 if ISO=="KGZ"
replace clock=8 if ISO=="LAO" & year==2005
replace clock=12 if ISO=="LAO" & dIndEmploy>.04
replace clock=9 if ISO=="LKA" & dELF<.08
replace clock=9 if ISO=="LVA"
replace clock=6 if ISO=="MKD"
replace clock=8 if ISO=="MNE"
replace clock=6 if ISO=="NZL" & dELF<0
replace clock=12 if ISO=="PAN"
replace clock=9 if ISO=="ROU"
replace clock=6 if ISO=="ROU" & dELF>0.1
replace clock=12 if ISO=="SGP"
replace clock=6 if ISO=="TJK"
replace clock=10 if ISO=="TON"
replace clock=1 if ISO=="VNM" & dIndEmploy>.05 & dIndEmploy<.08
replace clock=9 if ISO=="VNM" & dIndEmploy>.08
replace clock=6 if ISO=="ZAF"
twoway (lfitci dELF dIndEmploy) (scatter dELF dIndEmploy, mlabel(ISO) msize(small) mcolor(black) mlabcolor(black) mlabvpos(clock)) if dELF>-.2 & dIndEmploy>-.15, ytitle(Change in ELF) xtitle(Change in Employment in Industry) legend(off)

*Table 10.1: Industrialization and Ethnic Change with Year-Interaction Effects
xtreg elf lCO2pc CO2yearint MStock TT if pop50k==1 [aweight=Countryweight], fe cluster (countryid)
xtreg elf lCement Cementint MStock TT if pop50k==1 [aweight=Countryweight], fe cluster (countryid)
xtreg elf Urban Urbanint MStock TT if pop50k==1 [aweight=Countryweight], fe cluster (countryid)
xtreg elf lElectricityUSEIA ElectricityUSEIAint MStock TT if pop50k==1 [aweight=Countryweight], fe cluster (countryid)
xtreg elf AgEmploy AgEmployint MStock TT if pop50k==1 [aweight=Countryweight], fe cluster (countryid)
xtreg elf ManufactEmploy Manint MStock TT if pop50k==1 [aweight=Countryweight], fe cluster (countryid)

*Table 10.2: Industrialization and Ethnic Change with Year-Interaction Effects, Sub-Samples
xtreg elf lCO2pc CO2yearint MStock TT if pop50k==1 & Africa==0 [aweight=Countryweight], fe cluster (countryid)
xtreg elf lCO2pc CO2yearint MStock TT if pop50k==1 & Asia==0 [aweight=Countryweight], fe cluster (countryid)
xtreg elf lCO2pc CO2yearint MStock TT if pop50k==1 & Europe==0 [aweight=Countryweight], fe cluster (countryid)
xtreg elf lCO2pc CO2yearint MStock TT if pop50k==1 & Oceania==0 [aweight=Countryweight], fe cluster (countryid)
xtreg elf lCO2pc CO2yearint MStock TT if pop50k==1 & Americas==0 [aweight=Countryweight], fe cluster (countryid)
xtreg elf lCO2pc CO2yearint MStock TT if pop50k==1 & Americas==1 [aweight=Countryweight], fe cluster (countryid)

*Figure 10.1: Interaction Effects for Carbon Emissions and Year on ELF using Census Data
xtreg elf c.lCO2pc##c.year MStock if pop50k==1, fe cluster (countryid)
margins, at(lCO2pc=(-3(1)4) year=(1960 1980 2000 2020 2040))
marginsplot, recast(line) noci xtitle("Change in Carbon Emissions per capita (log)") plot1opts(lpattern(dot)) plot2opts(lpattern(shortdash dot)) plot3opts(lpattern(dash)) plot4opts(lpattern(longdash_dot )) plot5opts(lpattern(solid))

*Appendix A4.1, Panel B
summarize year elf lCO2pc MStock LargestEG if year>1959 & pop50k==1 & lCO2pc!=. & elf!=.

*Other results mentioned in Chapter 10
*No effect of a quadratic relationship for urbanization or sectoral employment
xtreg elf Urban Urbansq MStock TT if pop50k==1 [aweight=Countryweight], fe cluster (countryid)
xtreg elf AgEmploy AgEmploysq MStock TT if pop50k==1 [aweight=Countryweight], fe cluster (countryid)
xtreg elf ManufactEmploy ManufactEmploysq MStock TT if pop50k==1 [aweight=Countryweight], fe cluster (countryid)
